<div ng-controller="PostfeeCtrl" ng-init="addAction()">
    <ul class="sui-breadcrumb">
        <li><a href="#/postfee/list">{{'邮费'| translate}}</a></li>
        <li class="active">
            {{"创建"|translate}}
        </li>
    </ul>
    <div class="sui-form form-horizontal">
        <div class="control-group">
            <label class="control-label v-top">
                模板名称：
            </label>
            <div class="controls">
                <input id="name" type="text" name="name" ng-model="fareTemplate.name" />
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">
                是否包邮：
            </label>
            <div class="controls">
                <label data-toggle="radio" class="radio-pretty inline {{fareTemplate.is_incl_postage == 1?'checked':''}}">
                    <input type="radio" name="is_incl_postage" ng-model="fareTemplate.is_incl_postage" value="1"><span>卖家承担运费</span>
                </label>
                <label data-toggle="radio" class="radio-pretty inline {{fareTemplate.is_incl_postage == 2?'checked':''}}">
                    <input type="radio" name="is_incl_postage" ng-model="fareTemplate.is_incl_postage" value="2">
                    <span>自定义运费</span>
                </label>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">
                计价方式：
            </label>
            <div class="controls">
                <label data-toggle="radio1" class="radio-pretty inline {{fareTemplate.valuation_model == 1?'checked':''}}">
                    <input type="radio" name="valuation_model" ng-model="fareTemplate.valuation_model" value="1"><span>按件数</span>
                </label>
                <label data-toggle="radio1" class="radio-pretty inline {{fareTemplate.valuation_model == 2?'checked':''}}">
                    <input type="radio" name="valuation_model" ng-model="fareTemplate.valuation_model" value="2"><span>按重量</span>
                </label>
                <!-- <label data-toggle="radio1" class="radio-pretty inline {{fareTemplate.valuation_model == 3?'checked':''}}">
                    <input type="radio" name="valuation_model" ng-model="fareTemplate.valuation_model" value="3"><span>按体积</span>
                </label> -->
            </div>
        </div>
        <div class="control-group">
            <label class="control-label">
                运送方式：
            </label>
            <div class="controls">
                <div ng-show="fareTemplate.carry_modes" ng-repeat="(key, value) in fareTemplate.carry_modes">
                    <label data-toggle="checkbox" class="checkbox-pretty {{value.son_data.length?'checked':''}}">
                        <input type="checkbox" ng-click="isChecked($event,key)" ng-checked="{{value.son_data.length? 'checked': ''}}" /><span>{{key=="express"?"快递":key=="ems"?"EMS":key=="post"?"平邮":""}}</span>
                    </label>
                    <div ng-if="fareTemplate.is_incl_postage == 2 && value.son_data.length>0">
                        <table class="sui-table table-bordered-simple" style="width: 750px;margin-bottom: 0px;">
                            <tr>
                                <td style="width: 50%;">
                                    运送到
                                </td>
                                <td>
                                    {{fareTemplate.valuation_model == 1?"首件数(件)":(fareTemplate.valuation_model == 2?"首重(千克)":"首体积(立方米)")}}
                                </td>
                                <td>
                                    首费(元)
                                </td>
                                <td>
                                    {{fareTemplate.valuation_model == 1?"续件数(件)":(fareTemplate.valuation_model == 2?"续重(千克)":"续体积(立方米)")}}
                                </td>
                                <td>
                                    续费(元)
                                </td>
                                <td>
                                    操作
                                </td>
                            </tr>
                            <tr class="{{express.region == 1?'t-title':''}}" ng-repeat="express in value.son_data" style="border-top: 0px;">
                                <td style="width: 50%;">
                                    <span ng-if="express.region == 1" class="batch-default-title">
                                        默认运费
                                    </span>
                                    <div ng-if="express.region != 1">
                                        选择地区
                                        <mynewarea ng-model="express.region" disabledcitys="express.diabledCitys"></mynewarea>
                                        <div>
                                            <!-- <span ng-repeat="city_id in express.region">
                                                <city-name ng-model="city_id"></city-name>
                                            </span> -->
                                            <city-name ng-model="express.region"></city-name>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <input value="" type="number" class="sui-input input-small" ng-model="express.first_piece">
                                </td>
                                <td>
                                    <input value="" type="number" class="sui-input input-small" ng-model="express.first_amount">
                                </td>
                                <td>
                                    <input value="" type="number" class="sui-input input-small" ng-model="express.second_piece">
                                </td>
                                <td>
                                    <input value="" type="number" class="sui-input input-small" ng-model="express.second_amount">
                                </td>
                                <td>
                                    <!-- ng-if="express.region != 1" -->
                                    <button class="sui-btn btn-link" ng-click="carryModesDelete(fareTemplate.fare_id,express.id,express.carry_way,$index)">
                                        删除 </button>
                                </td>
                            </tr>
                        </table>
                        <!-- ng-show="$index == 0" -->
                        <div style="border-left: 1px solid #E6E6E6;border-right: 1px solid #E6E6E6;border-bottom: 1px solid #E6E6E6;">
                            <!-- {{is_quanguo[key]?"abc":"dddd"}} -->
                            <button ng-show="is_quanguo[key]" class="sui-btn btn-link" ng-click="addQuanGuo(key)" style="margin-left: -10px;">默认全国设置运费</button>
                            <button class="sui-btn btn-link" ng-click="addCity(key)" style="margin-left: -10px;">指定地区设置运费</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label"></label>
            <div class="controls">
                <button id="submit" class="sui-btn btn-primary" ng-click="postfeeAdd()" ng-disabled="!(fareTemplate.name && fareTemplate.is_incl_postage && fareTemplate.valuation_model && (fareTemplate.carry_modes['express'].son_data.length || fareTemplate.carry_modes['ems'].son_data.length || fareTemplate.carry_modes['post'].son_data.length))">
                    <span>{{'save'|translate}}</span>
                </button>
            </div>
        </div>
    </div>
</div>